//
//  UIBarButtonItem+Extension.swift
//  WiBoPM
//
//  Created by 陈俊峰 on 2017/1/5.
//  Copyright © 2017年 陈俊峰. All rights reserved.
//

import UIKit

//重写构造方法

extension UIBarButtonItem {
    
    convenience init(imageName:String?,title:String?,target:Any?,action:Selector?) {
        
        let btn = UIButton()
        btn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
        btn.setImage(UIImage(named:imageName ?? ""), for: .normal)
        btn.setImage(UIImage(named:imageName ?? "" + "_highlighted"), for: .highlighted)
        //if let 是什么意思?
        btn.setTitle(title, for: .normal)
        if let ac = action {
            btn.addTarget(target, action: ac, for: .touchUpInside)
        }
        
        btn.setTitleColor(UIColor.darkGray, for: .normal)
        btn.setTitleColor(UIColor.orange, for: .highlighted)
        btn.sizeToFit()
        
        self.init()
        
        self.customView = btn
    }
    
    
}
///变更控制器通知
extension Notification.Name {
    static let ChangeRootViewController:Notification.Name = Notification.Name(rawValue: "ChangeRootViewController")
}



